/*-------------------------------------------------------------------------
 * CLR版本:     4.0.30319.42000
 * 创建人:      song
 * 创建时间：   2024/4/9 17:56:20
 * 功 能：      流动模块
 *-------------------------------------------------------------------------*/

#if UNITY_EDITOR
namespace SCore.Editor.SShaderDraw
{
    using System.Collections.Generic;
    using UnityEditor;
    using UnityEngine;

    public class SFlowProGUI : SComponentGUIBase
    {
        SKeyWordProp _Flow;
        SFloatProp _FlowSpeed;
        STextureProp _FlowTex;
        SRangeProp _FlowStrength;

        SRangeProp _FlowOffest;
        SRangeProp _FlowUJumpU;
        SRangeProp _FlowUJumpV;
        SFloatProp _FlowTiling;

        public override void Changed()
        {
        }

        public override void DrawProperties()
        {
            if (_Flow.Exist)
            {
                GUILayout.BeginVertical("box");
                base.DrawPartTitle<float>(_Flow, Styles.Flow, 15f, new SPropBase[]
                {
                    _FlowTex, _FlowSpeed, _FlowStrength,
                    _FlowOffest, _FlowUJumpU, _FlowUJumpV, _FlowTiling
                });
                GUILayout.EndVertical();
            }
        }

        public override void RefreshProperties()
        {
            this.lProps.Clear();
            this.lProps.Add(_Flow);
            this.lProps.Add(_FlowTex);
            this.lProps.Add(_FlowSpeed);
            this.lProps.Add(_FlowStrength);
            this.lProps.Add(_FlowOffest);
            this.lProps.Add(_FlowUJumpU);
            this.lProps.Add(_FlowUJumpV);
            this.lProps.Add(_FlowTiling);
        }

        public SFlowProGUI(MaterialEditor materialEditor, Dictionary<string, MaterialProperty> dics) : base(
            materialEditor, dics)
        {
            _Flow = new SKeyWordProp("_Flow", Styles.Flow, materialEditor, dics, 0f, true,
                SShaderEditorHelpr.GetInternelStyle("BoldTextField"));
            _FlowSpeed = new SFloatProp("_FlowSpeed", Styles.FlowSpeed, materialEditor, dics, 1f);
            _FlowTex = new STextureProp("_FlowTex", Styles.FlowTex, materialEditor, dics, null);
            _FlowStrength = new SRangeProp("_FlowStrength", Styles.FlowStrength, materialEditor, dics, 0.1f, -0.2f,
                0.2f);
            _FlowOffest = new SRangeProp("_FlowOffest", Styles.FlowOffest, materialEditor, dics, 0f, 0f, 1f);
            _FlowUJumpU = new SRangeProp("_FlowUJumpU", Styles.FlowUJumpU, materialEditor, dics, 0f, -0.25f, 0.25f);
            _FlowUJumpV = new SRangeProp("_FlowUJumpV", Styles.FlowUJumpV, materialEditor, dics, 0f, -0.25f, 0.25f);
            _FlowTiling = new SFloatProp("_FlowTiling", Styles.FlowTiling, materialEditor, dics, 1f);
        }

        private class Styles
        {
            public static GUIContent Flow = new GUIContent("流动", "流动模块");
            public static GUIContent FlowSpeed = new GUIContent("流动速度", "流动速度");
            public static GUIContent FlowTex = new GUIContent("流动贴图", "流动贴图");
            public static GUIContent FlowStrength = new GUIContent("流动强度", "流动强度");
            public static GUIContent FlowOffest = new GUIContent("流动初始的偏移", "流动从流动图开始的地方");
            public static GUIContent FlowUJumpU = new GUIContent("流动图像周期U", "流动图像在多少频率能平衡");
            public static GUIContent FlowUJumpV = new GUIContent("流动图像周期V", "流动图像在多少频率能平衡");
            public static GUIContent FlowTiling = new GUIContent("流动图像平铺", "流动图像平铺");
        }
    }
}
#endif